home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / unix < prev   
Encoding:
Text File  |  1994-03-01  |  7.3 KB  |  334 lines

  1. #!/usr/local/bin/icmake -qi
  2.  
  3. /*
  4.  
  5.     If you want to use this file, it is assumed that you have (a former
  6.     version of) icmake installed in /usr/local/bin. If it's somewhere else,
  7.     please adapt the path /usr/local/bin in the line above.
  8.     
  9.     Also, check the file destinations.im for proper path settings !
  10.  
  11.         FBB
  12. */
  13.  
  14. #include "def/programs"
  15. #include "def/destinations"
  16.  
  17. /*      
  18.         The remainder of this script should not be altered, unless
  19.     you know what you're doing
  20. */
  21.  
  22. #define VERSION        "6.17"
  23.  
  24. #define LIB_ICRSS    "libicrss.a"
  25. #define LIB_ICMAKE    "libicmake.a"
  26. #define LIB_ICMPP    "libicmpp.a"
  27. #define LIB_ICMCOMP    "libicmcomp.a"
  28. #define LIB_ICMEXEC    "libicmexec.a"
  29. #define LIB_ICMUN    "libicmun.a"
  30. #define ZIP        "icmake.zip"
  31.  
  32. list
  33.         examples;
  34.     
  35. void check(string subdir)
  36. {
  37.     if (!exists(subdir))
  38.     {
  39.         printf("Creating subdirectory: ");
  40.         exec(MKDIR, subdir);
  41.     }
  42. }    
  43.  
  44. void initialize()
  45. {
  46.     examples = 
  47.     (list)"am"      +
  48.     (list)"backup"  +
  49.     (list)"bup"     +
  50.     (list)"ftpxfer" +
  51.     (list)"ds"      +
  52.     (list)"idir"    +
  53.     (list)"keep"    +
  54.         (list)"r"       +
  55.     (list)"tolower";
  56.  
  57.     check("bin");
  58.     check("binlinux");
  59.     check("bindos");
  60. }            
  61.             
  62. void makelib (string dir, string lib)
  63. {
  64.     list
  65.         cfiles,
  66.         ofiles;
  67.     string
  68.         ofile,
  69.         cfile;
  70.     int
  71.         i;
  72.  
  73.     printf ("---- Directory: ", dir, " ----\n");
  74.     chdir (dir);
  75.  
  76.     printf ("Checking .c files against library ", lib, "\n");        
  77.     cfiles = makelist ("*.c");
  78.     for (i = sizeof (cfiles) - 1; i >= 0; i--)
  79.     {
  80.         cfile = element (i, cfiles);
  81.         ofile = change_ext (cfile, ".o");
  82.         if 
  83.     (
  84.         cfile older lib 
  85.         ||
  86.             (exists (ofile) && ofile younger cfile)
  87.         )
  88.             cfiles -= (list) cfile;
  89.     }
  90.     for (i = 0; i < sizeof (cfiles); i++)
  91.         exec (CC, CFLAGS, element (i, cfiles));
  92.     
  93.     printf ("Checking .o files against library ", lib, "\n");
  94.     ofiles = makelist ("*.o");
  95.     if (ofiles)
  96.     {
  97.         exec (AR, ARFLAGS, lib, "*.o");
  98.     exec (RM, "*.o");
  99.     }
  100.     
  101.     chdir ("..");
  102. }
  103.  
  104. void makelibs ()
  105. {
  106.     printf ("\nMaking Run Time Support System library\n");
  107.     makelib ("rss", LIB_ICRSS);
  108.     
  109.     printf ("\nMaking lib for shell program icmake\n");
  110.     makelib ("make", LIB_ICMAKE);
  111.     
  112.     printf ("\nMaking lib for preprocessor icm-pp\n");
  113.     makelib ("pp", LIB_ICMPP);
  114.     
  115.     printf ("\nMaking lib for compiler icm-comp\n");
  116.     makelib ("comp", LIB_ICMCOMP);
  117.     
  118.     printf ("\nMaking lib for executor icm-exec\n");
  119.     makelib ("exec", LIB_ICMEXEC);
  120.     
  121.     printf ("\nMaking lib for unassembler icmun\n");
  122.     makelib ("un", LIB_ICMUN);
  123. }
  124.  
  125. void makeprog (string dir, string lib, string prog)
  126. {
  127.     string
  128.         rsslib;
  129.         
  130.     rsslib = "../rss/libicrss.a";
  131.  
  132.     printf ("---- Directory: ", dir, " ----\n");
  133.     chdir (dir);
  134.     
  135.     printf ("Checking prog ", prog, " against libs ", lib, 
  136.             " and ", rsslib, "\n");
  137.  
  138.     if (lib younger prog || rsslib younger prog)
  139.     {
  140.         exec (CC, "-o ../bin/" + prog, lib, rsslib);
  141.         exec (STRIP, "../bin/" + prog);
  142.     printf("Stripped version of ", prog, " in icmake/bin\n");
  143.     }            
  144.         
  145.     chdir ("..");
  146. }
  147.  
  148. void makeprogs ()
  149. {
  150.     makelibs ();
  151.     
  152.     printf ("\nMaking shell program icmake\n");
  153.     makeprog ("make", LIB_ICMAKE, "icmake");
  154.     
  155.     printf ("\nMaking unassembler program icmun\n");
  156.     makeprog ("un", LIB_ICMUN, "icmun");
  157.  
  158.     printf ("\nMaking unassembler program icm-pp\n");
  159.     makeprog ("pp", LIB_ICMPP, "icm-pp");
  160.     
  161.     printf ("\nMaking compiler program icm-comp\n");
  162.     makeprog ("comp", LIB_ICMCOMP, "icm-comp");
  163.     
  164.     printf ("\nMaking executor program icm-exec\n");
  165.     makeprog ("exec", LIB_ICMEXEC, "icm-exec");
  166. }
  167.  
  168. void inst (string prog)
  169. {
  170.     string
  171.         dest;
  172.  
  173.     printf ("---- Directory: icmake/bin ----\n");
  174.     chdir ("bin");
  175.     dest = BINDIR + "/" + prog;
  176.     
  177.     if (dest older prog)
  178.     {
  179.         if (prog == "icm-exec")
  180.         printf("Since icm-exec itself is running, you have to copy\n"
  181.             "icm-exec by hand.\n"
  182.         "Give the command\n"
  183.             "\t", CP, " bin/icm-exec ", BINDIR, "\n"
  184.         "on completion of 'icmake unix -- install'\n");
  185.     else
  186.         exec (CP, prog, BINDIR);
  187.     }
  188.     
  189.     chdir ("..");
  190. }
  191.  
  192. void install ()
  193. {
  194.     makeprogs ();
  195.     
  196.     printf ("\nInstalling shell program icmake\n");
  197.     inst ("icmake");
  198.     
  199.     printf ("\nInstalling unassembler program icmun\n");
  200.     inst ("icmun");
  201.     
  202.     printf ("\nInstalling unassembler program icm-pp\n");
  203.     inst ("icm-pp");
  204.     
  205.     printf ("\nInstalling compiler program icm-comp\n");
  206.     inst ("icm-comp");
  207.     
  208.     printf ("\nUSE HAND-INSTALLATION OF EXECUTOR PROGRAM ICM-EXEC\n");
  209.     inst ("icm-exec");
  210. }
  211.  
  212. void clean (string dir, string lib)
  213. {
  214.     printf ("---- Directory: ", dir, " ----\n");
  215.     chdir (dir);
  216.     exec (RM, "-f", lib, "*.o");
  217.     chdir ("..");
  218. }
  219.  
  220. void cleanup ()
  221. {
  222.     clean ("rss", LIB_ICRSS);
  223.     clean ("make", LIB_ICMAKE);
  224.     clean ("pp", LIB_ICMPP);
  225.     clean ("comp", LIB_ICMCOMP);
  226.     clean ("exec", LIB_ICMEXEC);
  227.     clean ("un", LIB_ICMUN);
  228. }
  229.  
  230. void zip ()
  231. {
  232.     cleanup ();
  233.     
  234.     exec (RM, "-f", "bin/*", "../icmake.zip");
  235.     chdir ("..");
  236.     exec ("zip", "-r", ZIP, "icmake/*");
  237. }
  238.  
  239. void makedist ()
  240. {
  241.     string
  242.         tar,
  243.         example;
  244.     int
  245.         i;
  246.         
  247.     printf ("Have you updated the version number (if things have changed)?\n"
  248.             "Also, check distribution numbers in doc/icmake.1 and icmake.doc\n"
  249.         "\n"
  250.             "The version used now is: ", VERSION, ".\n"
  251.         "Do you want to continue [y/n] ");
  252.     if (getch () != "y")
  253.         return;
  254.  
  255.     printf ("\nOk..\n");
  256.     
  257.     chdir ("examples");
  258.     for (i = 0; i < sizeof (examples); i++)
  259.     {
  260.         example = element (i, examples);
  261.         if ("/home/karel/bin/" + example younger example)
  262.             exec (CP, "/home/karel/bin/" + example, example);
  263.         else if ("/usr/local/bin/" + example younger example)
  264.             exec (CP, "/usr/local/bin/" + example, example);
  265.     }
  266.  
  267.     chdir ("../..");
  268.  
  269.     tar = "icmake-" + VERSION + ".tgz";
  270.     exec (RM, "-f", tar);
  271.     exec ("tar", "-c -z -v --exclude-from icmake/distrib.no -f", 
  272.                         tar, "icmake");
  273.             
  274.     tar = "icmake-" + VERSION + ".bin.tgz";
  275.     exec (RM, "-f", tar);
  276.     exec ("tar", "-c -z -v --files-from icmake/bindist.yes -f", 
  277.                         tar, "icmake");
  278. }
  279.  
  280. void doc2man ()
  281. {
  282.     string
  283.         src,
  284.     dest,
  285.     zdest;
  286.         
  287.     src   = "doc"   + "/" + "icmake.1";
  288.     dest  = CATDIR  + "/" + "icmake.1";
  289.     zdest = CATDIR  + "/" + "icmake.1.Z";
  290.     
  291.     if (zdest older src)
  292.     {
  293.         exec (CP, src, CATDIR);
  294.     exec (COMPRESS, "-f", dest);
  295.     }
  296. }
  297.  
  298. void main (int argc, list argv)
  299. {
  300.     string
  301.         av1;
  302.     
  303.     initialize();    
  304.         
  305.     av1 = element (1, argv);
  306.     if (av1 == "libs")
  307.         makelibs ();
  308.     else if (av1 == "progs")
  309.         makeprogs ();
  310.     else if (av1 == "install")
  311.         install ();
  312.     else if (av1 == "clean")
  313.         cleanup ();
  314.     else if (av1 == "doc2man")
  315.         doc2man ();
  316.     else if (av1 == "zip")
  317.         zip ();
  318.     else if (av1 == "dist")
  319.     makedist ();
  320.     else
  321.         printf ("\n"
  322.             "Select one of the following:\n"
  323.             "    \"unix libs\" to make libraries\n"
  324.             "    \"unix progs\" to make programs\n"
  325.             "    \"unix install\" to install programs to ",
  326.                                 BINDIR, "\n"
  327.         "    \"unix clean\" to remove old mush\n"
  328.         "    \"unix doc2man\" to install crude docs to cat\n"
  329.         "\n"
  330.         "    \"unix zip\" to clean up and zip it up\n"
  331.         "    \"unix dist\" to make distribution\n"
  332.             "\n");
  333. }
  334.